/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *  iPhoneRrVAppDelegate.m - iPhoneSRV console for Surveyor SRV-1 and SVS 
 *
 *  Created by Nick Kitchener.  Copyright (C) 2009  Surveyor Corporation 
 *            and Nick Kitchener.  All rights reserved.
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details (www.gnu.org/licenses)
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#import "iPhoneSRVAppDelegate.h"

@implementation iPhoneSRVAppDelegate
@synthesize window, connectionViewController, immediateViewController;
@synthesize leftBlackfin, rightBlackfin;
@synthesize configuration;

- (void)applicationDidFinishLaunching:(UIApplication *)application {
    NSArray*    topLevelObjs = nil;
    NSDictionary*    proxies = [NSDictionary dictionaryWithObject:self forKey:@"flibble"];
    NSDictionary*    options = [NSDictionary dictionaryWithObject:proxies forKey:UINibExternalObjects];
	
    topLevelObjs = [[NSBundle mainBundle] loadNibNamed:@"SRVConnectionViewController" owner:connectionViewController options:options];
    if ([topLevelObjs count] == 0)
    {
        NSLog(@"Warning! Could not substitute proxy objects in xib file.\n");
        return;
    }
	
	[configuration loadApplicationPreferences];
	[window addSubview:connectionViewController.view];
	
	[immediateViewController.view setFrame:[[UIScreen mainScreen] applicationFrame]];
	[connectionViewController.view setFrame:[[UIScreen mainScreen] applicationFrame]];
	
	[window makeKeyAndVisible];
		
	[connectionViewController startConnectionProbe];	
}

- (void)applicationWillTerminate:(UIApplication *)application {
}

- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
	NSLog(@"Low memory warning received");
}

- (void)dealloc {
	[super dealloc];
}



-(IBAction)okButtonPressed:(id)sender {
	[window addSubview:immediateViewController.view];
	[window setRootViewController:immediateViewController];
	[connectionViewController.view removeFromSuperview];
}

@end

